require 'login_system'
class Plugin::CatgraphController < ActionController::Base
  before_filter :set_site_template_root
  def set_site_template_root
    self.class.template_root = "#{RAILS_ROOT}/components/"
    @template.base_path = template_root
  end
  include LoginSystem
  before_filter :login_required, :only => [:config]  
  
  
  def show
    @plugin=Extplugin.find_by_name("catgraph")
    @config=@plugin.config
    @datas=Category.find(:all)
    @names=Array.new
    @values=Array.new
	  for d in @datas
      n=Media.find_all_by_category_id(d.id).size
	    @names+=[d.name+" ("+n.to_s+")"]
	    @values+=[n]
    end
    if @plugin.activated==1
  	  render(:layout => false)
  	else
  	  render :text => _("not activated")
  	end
  end

  def config
    @plugin=Extplugin.find_by_name("catgraph")
    @config=@plugin.config 
  end

end